﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mamnontuoitho7.AppCode;
using System.Data;

namespace mamnontuoitho7.backend
{
    public partial class ClassNotice : System.Web.UI.Page
    {

        private Notice _notice = new Notice();
        private Member _member = new Member();
        protected General _general = new General();

        protected DataTable _dttClassNotice;
        protected String _className = "";
        protected String _classID = "";

        protected void Page_Load(object sender, EventArgs e)
        {

            //Check Role Admin
            if (Session["memberID"].ToString() != "" && (ConstantClass.permissionInfo).IndexOf(Session["role"].ToString() + ",") != -1)
            {
                try
                {
                    if (!IsPostBack)
                    {
                        if (Request.QueryString["hidClassID"] != null && Request.QueryString["hidClassName"] != null)
                        {
                            _classID = Request.QueryString["hidClassID"].ToString();
                            _className = Request.QueryString["hidClassName"].ToString();

                            //Delete Notice
                            if (Request.Form["hidClassNoticeID"] != null && Request.Form["hidClassNoticeID"].ToString() != "")
                            {
                                _notice.NoticeDelete(Request.Form["hidClassNoticeID"].ToString());

                            }
                            loadNoticeList(Request.QueryString["hidClassID"].ToString());
                        }

                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Response.Redirect(ConstantClass._errorAdminPage);
                }
            }
            else
            {
                Response.Redirect(ConstantClass._errorLoginPage);
            }
        }


        /// <summary>
        /// Get notice list of a class
        /// </summary>
        private void loadNoticeList(String classID)
        {
            _dttClassNotice = _notice.GetClassNotice(classID);

        }
    }
}